<include file="public@header"/>
<style type="text/css">

.item {
float: left;
clear: both;
margin-bottom: 5px;
}
/* 向上的箭头 */

.arrow-top {
font-size: 0;
line-height: 0;
border-width: 5px;
border-color: #18BC9C;
border-top-width: 0;
border-style: dashed;
border-bottom-style: solid;
border-left-color: transparent;
border-right-color: transparent;
}

/* 向下的箭头 */

.arrow-bottom {
font-size: 0;
line-height: 0;
border-width: 5px;
border-color: #18BC9C;
border-bottom-width: 0;
border-style: dashed;
border-top-style: solid;
border-left-color: transparent;
border-right-color: transparent;
}


.fl{
    float: left;
}
.fr{
    float: right;
}
.clear{
    clear: both;
}
</style>
</head>
<body>
<div class="wrap">
    <!--<ul class="nav nav-tabs">-->
    <!--    <li class="active"><a>{:lang('USER_INDEXADMIN_INDEX')}</a></li>-->
    <!--    <li><a href="{:url('adminIndex/add')}">添加主播</a></li>-->
    <!--</ul>-->
    <form name="search" class="well form-inline margin-top-20" method="post" action="{:url('admin/Country/index')}">
        
		 是否推荐：
        <select class="form-control" name="recommend">
            <option value="">全部</option>
            <option value="2" <if condition="input('request.recommend') neq '' && input('request.recommend') eq 2">selected</if>>是</option>
            <option value="1" <if condition="input('request.recommend') neq '' && input('request.recommend') eq 1">selected</if>>否</option>
        </select>
		
        关键字：
        <input class="form-control" type="text" name="keyword" style="width: 200px;" value="{:input('request.keyword')}"
               placeholder="name/code">
        <!--<input class="form-control" type="hidden" name="coin_status" value="{:input('request.coin_status')}" >-->
        <!--<input class="form-control" type="hidden" name="consumption_status" value="{:input('request.consumption_status')}" >-->
        <!--<input class="form-control" type="hidden" name="votes_status" value="{:input('request.votes_status')}" >-->
        <!--<input class="form-control" type="hidden" name="votestotal_status" value="{:input('request.votestotal_status')}" >-->
        <!--<input class="form-control" type="hidden" name="createtime_status" value="{:input('request.createtime_status')}" >-->

        <input type="submit" class="btn btn-primary" value="搜索"/>
        <a class="btn btn-danger" href="{:url('admin/Country/index')}">清空</a>
		<br>
		<br>
		国家数量：{$nums}  (根据条件统计)
    </form>
    <form method="post" class="js-ajax-form">
        <table class="table table-hover table-bordered">
            <thead>
            <tr>
                <th>ID</th>
                <th>国家名称</th>
                <th>国家中文名称</th>
                <th>货币单位</th>
                <th>货币符号</th>
                <th>是否推荐</th>
                <th>索引</th>
                <th>{:lang('ACTIONS')}</th>
            </tr>
            </thead>
            <tbody>
            
            <foreach name="list" item="vo">
                <tr>
                    <td>{$vo.id}</td>
                    <td>{$vo.name}</td>
                    <td>{$vo.name_cn}</td>
                    <td>{$vo.unit}</td>
                    <td>{$vo.mark}</td>
                    <td>
                        <switch name="vo.recommend">
                            <case value="1">
                                <span class="label label-danger">否</span>
                            </case>
                            <case value="2">
                                <span class="label label-success">是</span>
                            </case>
                            
                        </switch>
                    </td>
                    <td>{$vo.title}</td>
                    <td>
                        <a class="btn btn-xs btn-primary" href='{:url("Country/edit",array("id"=>$vo["id"]))}'>{:lang('EDIT')}</a>
<!--                        <a class="btn btn-xs btn-danger js-ajax-delete" href="{:url('Country/del',array('id'=>$vo['id']))}">{:lang('DELETE')}</a>-->
                    </td>
                </tr>
            </foreach>
            </tbody>
        </table>
        <div class="pagination">{$page}</div>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
    <script>
        $(function(){

            Wind.use('layer');
            $('.setrecommend').click(function(){
                var _this=$(this);
                var uid=_this.data('uid');
                var recommend=_this.data('value');

                layer.prompt({
                    formType: 0,
                    title: '推荐值',
                    value: recommend,
                }, function(value, index, elem){
                    $.ajax({
                        url:'{:url('user/adminIndex/setrecommend')}',
                        type:'POST',
                        data:{uid:uid,recommend:value},
                        dataType:'json',
                        success:function(data){
                            var code=data.code;
                            if(code==0){
                                layer.msg(data.msg);
                                return !1;
                            }
                            layer.msg(data.msg,{},function(){
                                layer.closeAll();
                                location.reload();
                            });
                            
                        },
                        error:function(){
                            layer.msg('操作失败，请重试')
                        }
                    });
                    
                });
                
            });

            //钻石由低到高排序
            $(".coin_top .arrow-top").on('click',function(){
                //layer.msg("钻石向上");
                change_status('coin','1');
            });
            //钻石由高到低排序
            $(".coin_top .arrow-bottom").on('click',function(){
                //layer.msg("钻石向下");
                change_status('coin','-1');
            });

            //总消费由低到高排序
            $(".consumption_top .arrow-top").on('click',function(){
                //layer.msg("总消费向上");
                change_status('consumption','1');
            });

            //总消费由高到低排序
            $(".consumption_top .arrow-bottom").on('click',function(){
                //layer.msg("总消费向下");
                change_status('consumption','-1');
            });

            //映票由低到高排序
            $(".votes_top .arrow-top").on('click',function(){
                //layer.msg("映票向上");
                change_status('votes','1');
            });

            //映票由高到低排序
            $(".votes_top .arrow-bottom").on('click',function(){
                //layer.msg("映票向下");
                change_status('votes','-1');
            });

            
            //总收益由低到高排序
            $(".votestotal_top .arrow-top").on('click',function(){
                //layer.msg("总收益向上");
                change_status('votestotal','1');
            });

            //总收益由高到低排序
            $(".votestotal_top .arrow-bottom").on('click',function(){
                //layer.msg("总收益向下");
                change_status('votestotal','-1');
            });

            //注册时间正序排序
            $(".createtime_top .arrow-top").on('click',function(){
                //layer.msg("正序");
                change_status('createtime','1');
            });

            //注册时间倒序排序
            $(".createtime_top .arrow-bottom").on('click',function(){
                //layer.msg("倒序");
                change_status('createtime','-1');
            });
        })

        function change_status(current,val){
            $("input[name='"+current+"_status']").val(val);
            var arr=['coin','consumption','votes','votestotal','createtime'];
            for (var i = 0; i < arr.length; i++) {
                if(arr[i]!=current){
                    $("input[name='"+arr[i]+"_status']").val('');
                }
            }

            $("form[name='search']").submit();
        }
    </script>
</body>
</html>